package com.hbusa.cotroller.novel;

import com.hbusa.dto.TbNovels;
import com.hbusa.service.service.impl.NovelsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.ArrayList;

/**
 * @author Sandwich
 * @version 1.0
 * @date 2021/12/27-3:59
 */
@WebServlet("/doNovelFindAll")
public class novelFindAllServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("utf-8");
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;utf-8");

        NovelsServiceImpl novelsService = new NovelsServiceImpl();
        ArrayList<TbNovels> all = novelsService.findAll();

        HttpSession session = req.getSession();
        session.setAttribute("all",all);

        resp.sendRedirect("admin/novelFindAll.jsp");
    }
}
